/*
 * 人人信用管理有限公司版权所有.
 * 
 * @Description:
 * 
 * @author: liyuliang
 * 
 * @date: 20 Apr 2017 10:44:16 am
 * 
 * 注意：本内容仅限于人人信用管理有限公司内部传阅，禁止外泄以及用于其他的商业目的.
 */

package com.rrx360.common.web.auth;

import com.rrx360.common.config.global.GlobalConfig;
import com.rrx360.common.exception.RException;

public class AuthUtil {

  private static RrxAuthenticator authenticator;

  static {
    String authClass = GlobalConfig.get("rxAuthenticator.class");
    if (authClass != null) {
      try {
        authenticator = (RrxAuthenticator) Class.forName(authClass).newInstance();
      } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new RException(e);
      }
    }
  }

  public static RrxAuthenticator getAuthenticator() {
    return authenticator;
  }

  public static boolean auth(String auth) {
    return getAuthenticator().auth(new String[] {auth}, null);
  }

  public static boolean auth(String[] auths) {
    return getAuthenticator().auth(auths, null);
  }

}
